cmake_minimum_required(VERSION 3.8)
project(g29_ros2_feedback) 

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(std_msgs REQUIRED)
find_package(rclcpp REQUIRED)
# new add---------------------
find_package(g29_msg REQUIRED)
# new add---------------------
# 查找 X11 库
find_package(X11 REQUIRED)

foreach(dirname ${CMAKE_CURRENT_SOURCE_DIR}/src)
    file(GLOB_RECURSE SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
            "${dirname}/*.h"
            "${dirname}/*.hpp"
            "${dirname}/*.c"
            "${dirname}/*.cpp"
            )
endforeach()

add_executable(${PROJECT_NAME}_node ${SRC})

target_include_directories(${PROJECT_NAME}_node PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
  ${X11_INCLUDE_DIR}  # 添加 X11 头文件路径
  )
target_compile_features(${PROJECT_NAME}_node PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17
ament_target_dependencies(
  ${PROJECT_NAME}_node
  "std_msgs"
  "rclcpp"
  g29_msg
)

# 显式链接 X11 库
target_link_libraries(${PROJECT_NAME}_node
  ${X11_LIBRARIES}   # 添加 X11 库
)

install(TARGETS ${PROJECT_NAME}_node
  DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  set(ament_cmake_copyright_FOUND TRUE)
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
